import * as actionTypes from './constants';

import { getAdminMessage } from '../../services';

const changeAdminMessage = (res) => ({
    type: actionTypes.CHANGE_ADMIN_MESSAGE,
    adminMessage: res.data
})


export const getAdminMessageAction = () => {
    //函数的返回值仍然是一个函数

    return dispatch => {
        //在这里进行网络请求的发送
        getAdminMessage().then(res => {
            //console.log(res);  //这里可以获取到所需要的内容
            dispatch(changeAdminMessage(res))
        })
    }
}